<template>
  <div class="mr-root">
    <back-header> </back-header>
    <div class="introduce">
      <!--更换页面内容-->
      <div @click="reduce">上一章</div>
      <div @click="more">下一章</div>
    </div>
    <loading v-if="showLoading"></loading>
    <back-top></back-top>
    <!--内容渲染-->
    <div class="content">
      <div v-for="a in List">
        <img :src=a.images alt="" class="img">
      </div>
    </div>
  </div>
</template>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<script>
  import BackHeader from "../commpoents/BackHeader"
  import Loading from '../commpoents/Loading'
  import BackTop from '../commpoents/BackTop'
  export default {
    components: {
      BackHeader,
      Loading,
      BackTop
    },

    data() {
      return {
        List: [],
        num: 1,
        shu: 1,
        showLoading: true
      }
    },

    created() {
      this.one(this.num)

    },

    methods: {
      one(num) {
        this.axios.get(
            `https://api.maimengjun.com/index.php?r=cartoonChapter/albumListByOrder&cartoonId=${this.$route.params.id}&priority=${num}&isSize=1`
          )
          .then(data => {
             this.List = data.data.results
             setTimeout(() => {
              this.showLoading = false
            }, 300)
          })
          .catch(err => {
            console.log(err)
          })
      },
      // 上与下章页面更换
      reduce() {
        this.num--
         this.one(this.num)
        if (this.num <1) {
          this.one(1)
          this.$alert('亲，这已经是第一章了，请查看其他章节', '快看漫画', {
            confirmButtonText: '确定',
          })

        }
      },

      more() {
        this.num++
          this.one(this.num)
        setTimeout(() => {
          this.showLoading = false
         }, 300)
        var text = this.$route.params.number
         var value = text.replace(/[^0-9]/ig, "");
         if (this.num > value) {
          this.one(value)
          this.$alert('亲，这已经是第一章了，请查看其他章节', '快看漫画', {
            confirmButtonText: '确定',
          })
         }
       }
      }
  }

</script>
<style scoped>
  .mr-root back-header {
    color: red;
  }

  .content {
    padding: 0 30px;
    margin-top: 1.1rem;
  }

  .img {
    width: 100%;
    height: 50%;
  }

  .introduce {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
  }

  .introduce div {
    width: 24%;
    text-align: center;
    border: solid 1px black;
    padding: 0.2rem;
    box-sizing: border-box;
    font-size: 0.4rem;
  }

  .el-notification__group[] {
    font-size: 5rem;
  }

  .active {
    color: red;
  }

  #one::before {
    content: "目前更新的章节";
  }

  #one {
    display: none;
  }

  .el-message-box__wrapper {
   top: 2rem !important;
  }

</style>
